package pro.cherish.knowledgedemoioc.thread;


import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import pro.cherish.knowledgedemoioc.service.UserService;
import pro.cherish.knowledgedemoioc.util.SpringUtil;

import java.util.concurrent.Callable;

/**
 * @author 创建人：cherish
 * @version 版本号：V1.0
 * <p>
 * ***************************修订记录************************************
 * 2019-09-28 cherish 创建该类功能。
 * **********************************************************************
 * </p>
 * @ClassName 类名：SpeekThreadHandler
 * @Description 功能说明：使用spring util 工具注入【获取spring 容器，从中获取bean注入】
 * <p>
 * TODO
 * </p>
 * **********************************************************************
 * @date 创建日期： 2019-09-28 cherish
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SpeekThreadHandler implements Callable {

    private UserService userService = SpringUtil.getApplicationContext().getBean("userService", UserService.class);
    private String name;

    public SpeekThreadHandler(String name) {
        this.name = name;
    }


    @Override
    public Object call() throws Exception {
        Object user = userService.getUser();
        System.out.println(user);
        System.out.println("线程" + Thread.currentThread().getName() + "调用了，获取到了name " + name);
        return "我知道了";
    }
}
